<template>
  <!-- 切换多语言 -->
  <el-dropdown trigger="click" @command="changeLanguage">
    <div>
      <svg-icon style="color:#666;font-size:20px" icon-class="language" class="svgIcon"></svg-icon>
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="$i18n.locale === 'zh'" command="zh">中文</el-dropdown-item>
      <el-dropdown-item :disabled="$i18n.locale === 'en'" command="en">en</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookies from 'js-cookie';
export default {
  name: '',
  components: {},
  props: {},
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    changeLanguage(type) {
      Cookies.set('language', type);
      this.$i18n.locale = type;
      this.$message.success('切换多语言成功');
      const a = this.$i18n.locale;
      const b = this.$i18n.messages;
      this.$emit('changeLanguage', b[a]);
    }
  }
};
</script>
<style lang="scss" scoped></style>
